XSETTYPE (val, Lisp_Process);
p = XPROCESS (val);
- XFASTINT (p->infd) = 0;
- XFASTINT (p->outfd) = 0;
+ XSET (p->infd, Lisp_Int, -1);
+ XSET (p->outfd, Lisp_Int, -1);
XFASTINT (p->pid) = 0;
XFASTINT (p->tick) = 0;
XFASTINT (p->update_tick) = 0;
XPROCESS (proc)->status = Fcons (Qexit, Fcons (make_number (0), Qnil));
XSETINT (XPROCESS (proc)->tick, ++process_tick);
}
- else if (XFASTINT (XPROCESS (proc)->infd))
+ else if (XINT (XPROCESS (proc)->infd >= 0))
{
Fkill_process (proc, Qnil);
/* Do this now, since remove_process will make sigchld_handler do nothing. */
{
CHECK_PROCESS (proc, 0);
if (EQ (filter, Qt))
- FD_CLR (XPROCESS (proc)->infd, &input_wait_mask);
+ FD_CLR (XINT (XPROCESS (proc)->infd), &input_wait_mask);
else if (EQ (XPROCESS (proc)->filter, Qt))
- FD_SET (XPROCESS (proc)->infd, &input_wait_mask);
+ FD_SET (XINT (XPROCESS (proc)->infd), &input_wait_mask);
XPROCESS (proc)->filter = filter;
return filter;
}
/* Record this as an active process, with its channels.
As a result, child_setup will close Emacs's side of the pipes. */
chan_process[inchannel] = process;
- XFASTINT (XPROCESS (process)->infd) = inchannel;
- XFASTINT (XPROCESS (process)->outfd) = outchannel;
+ XSET (XPROCESS (process)->infd, Lisp_Int, inchannel);
+ XSET (XPROCESS (process)->outfd, Lisp_Int, outchannel);
/* Record the tty descriptor used in the subprocess. */
if (forkin < 0)
XPROCESS (process)->subtty = Qnil;
XPROCESS (proc)->filter = Qnil;
XPROCESS (proc)->command = Qnil;
XPROCESS (proc)->pid = Qnil;
- XFASTINT (XPROCESS (proc)->infd) = s;
- XFASTINT (XPROCESS (proc)->outfd) = outch;
+ XSET (XPROCESS (proc)->infd, Lisp_Int, s);
+ XSET (XPROCESS (proc)->outfd, Lisp_Int, outch);
XPROCESS (proc)->status = Qrun;
FD_SET (inch, &input_wait_mask);
register int inchannel, outchannel;
register struct Lisp_Process *p = XPROCESS (proc);
- inchannel = XFASTINT (p->infd);
- outchannel = XFASTINT (p->outfd);
+ inchannel = XINT (p->infd);
+ outchannel = XINT (p->outfd);
- if (inchannel)
+ if (inchannel >= 0)
{
/* Beware SIGCHLD hereabouts. */
flush_pending_output (inchannel);
}
#else
close (inchannel);
- if (outchannel && outchannel != inchannel)
+ if (outchannel >= 0 && outchannel != inchannel)
close (outchannel);
#endif
- XFASTINT (p->infd) = 0;
- XFASTINT (p->outfd) = 0;
+ XSET (p->infd, Lisp_Int, -1);
+ XSET (p->outfd, Lisp_Int, -1);
chan_process[inchannel] = Qnil;
FD_CLR (inchannel, &input_wait_mask);
}
process = chan_process[i];
if (!NILP (process))
{
- int in = XFASTINT (XPROCESS (process)->infd);
- int out = XFASTINT (XPROCESS (process)->outfd);
- if (in)
+ int in = XINT (XPROCESS (process)->infd);
+ int out = XINT (XPROCESS (process)->outfd);
+ if (in >= 0)
close (in);
- if (out && in != out)
+ if (out >= 0 && in != out)
close (out);
}
}
Lisp_Object proc;
EMACS_TIME timeout, end_time, garbage;
SELECT_TYPE Atemp;
- int wait_channel = 0;
+ int wait_channel = -1;
struct Lisp_Process *wait_proc = 0;
int got_some_input = 0;
Lisp_Object *wait_for_cell = 0;
if (XTYPE (read_kbd) == Lisp_Process)
{
wait_proc = XPROCESS (read_kbd);
- wait_channel = XFASTINT (wait_proc->infd);
+ wait_channel = XINT (wait_proc->infd);
XFASTINT (read_kbd) = 0;
}
redisplay_preserve_echo_area ();
if (XINT (read_kbd) && detect_input_pending ())
- nfds = 0;
+ {
+ nfds = 0;
+ FD_ZERO (&Available);
+ }
else
nfds = select (MAXDESC, &Available, 0, 0, &timeout);
if (XINT (read_kbd) || wait_for_cell)
do_pending_window_change ();
- /* Check for data from a process or a command channel */
- for (channel = FIRST_PROC_DESC; channel < MAXDESC; channel++)
+ /* Check for data from a process. */
+ /* Really FIRST_PROC_DESC should be 0 on Unix,
+ but this is safer in the short run. */
+ for (channel = keyboard_descriptor == 0 ? FIRST_PROC_DESC : 0;
+ channel < MAXDESC; channel++)
{
if (FD_ISSET (channel, &Available))
{
waiting. */
if (wait_channel == channel)
{
- wait_channel = 0;
+ wait_channel = -1;
time_limit = -1;
got_some_input = 1;
}
if (this > 500)
this = 500;
old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap);
- rv = write (XFASTINT (XPROCESS (proc)->outfd), buf, this);
+ rv = write (XINT (XPROCESS (proc)->outfd), buf, this);
signal (SIGPIPE, old_sigpipe);
if (rv < 0)
{
if (!EQ (p->childp, Qt))
error ("Process %s is not a subprocess",
XSTRING (p->name)->data);
- if (!XFASTINT (p->infd))
+ if (XINT (p->infd) < 0)
error ("Process %s is not active",
XSTRING (p->name)->data);
switch (signo)
{
case SIGINT:
- tcgetattr (XFASTINT (p->infd), &t);
+ tcgetattr (XINT (p->infd), &t);
send_process (proc, &t.c_cc[VINTR], 1);
return;
case SIGQUIT:
- tcgetattr (XFASTINT (p->infd), &t);
+ tcgetattr (XINT (p->infd), &t);
send_process (proc, &t.c_cc[VQUIT], 1);
return;
case SIGTSTP:
- tcgetattr (XFASTINT (p->infd), &t);
+ tcgetattr (XINT (p->infd), &t);
#ifdef VSWTCH
send_process (proc, &t.c_cc[VSWTCH], 1);
#else
switch (signo)
{
case SIGINT:
- ioctl (XFASTINT (p->infd), TIOCGETC, &c);
+ ioctl (XINT (p->infd), TIOCGETC, &c);
send_process (proc, &c.t_intrc, 1);
return;
case SIGQUIT:
- ioctl (XFASTINT (p->infd), TIOCGETC, &c);
+ ioctl (XINT (p->infd), TIOCGETC, &c);
send_process (proc, &c.t_quitc, 1);
return;
#ifdef SIGTSTP
case SIGTSTP:
- ioctl (XFASTINT (p->infd), TIOCGLTC, &lc);
+ ioctl (XINT (p->infd), TIOCGLTC, &lc);
send_process (proc, &lc.t_suspc, 1);
return;
#endif /* ! defined (SIGTSTP) */
switch (signo)
{
case SIGINT:
- ioctl (XFASTINT (p->infd), TCGETA, &t);
+ ioctl (XINT (p->infd), TCGETA, &t);
send_process (proc, &t.c_cc[VINTR], 1);
return;
case SIGQUIT:
- ioctl (XFASTINT (p->infd), TCGETA, &t);
+ ioctl (XINT (p->infd), TCGETA, &t);
send_process (proc, &t.c_cc[VQUIT], 1);
return;
#ifdef SIGTSTP
case SIGTSTP:
- ioctl (XFASTINT (p->infd), TCGETA, &t);
+ ioctl (XINT (p->infd), TCGETA, &t);
send_process (proc, &t.c_cc[VSWTCH], 1);
return;
#endif /* ! defined (SIGTSTP) */
if (!NILP (p->subtty))
err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid);
else
- err = ioctl (XFASTINT (p->infd), TIOCGPGRP, &gid);
+ err = ioctl (XINT (p->infd), TIOCGPGRP, &gid);
#ifdef pfa
if (err == -1)
sys$forcex (&(XFASTINT (p->pid)), 0, 1);
whoosh:
#endif
- flush_pending_output (XFASTINT (p->infd));
+ flush_pending_output (XINT (p->infd));
break;
}
/* gid may be a pid, or minus a pgrp's number */
#ifdef TIOCSIGSEND
if (!NILP (current_group))
- ioctl (XFASTINT (p->infd), TIOCSIGSEND, signo);
+ ioctl (XINT (p->infd), TIOCSIGSEND, signo);
else
{
gid = - XFASTINT (p->pid);
#ifdef DID_REMOTE
{
char buf[1];
- write (XFASTINT (XPROCESS (proc)->outfd), buf, 0);
+ write (XINT (XPROCESS (proc)->outfd), buf, 0);
}
#else /* did not do TOICREMOTE */
#ifdef VMS
send_process (proc, "\004", 1);
else
{
- close (XPROCESS (proc)->outfd);
- XFASTINT (XPROCESS (proc)->outfd) = open (NULL_DEVICE, O_WRONLY);
+ close (XINT (XPROCESS (proc)->outfd));
+ XSET (XPROCESS (proc)->outfd, Lisp_Int, open (NULL_DEVICE, O_WRONLY));
}
#endif /* VMS */
#endif /* did not do TOICREMOTE */
{
if (NETCONN_P (proc))
deactivate_process (proc);
- else if (XFASTINT (XPROCESS (proc)->infd))
+ else if (XINT (XPROCESS (proc)->infd) >= 0)
process_send_signal (proc, SIGHUP, Qnil, 1);
}
}
/* If process has terminated, stop waiting for its output. */
if (WIFSIGNALED (w) || WIFEXITED (w))
- if (XFASTINT (p->infd))
- FD_CLR (XFASTINT (p->infd), &input_wait_mask);
+ if (XINT (p->infd) >= 0)
+ FD_CLR (XINT (p->infd), &input_wait_mask);
/* Tell wait_reading_process_input that it needs to wake up and
look around. */
XSETINT (p->update_tick, XINT (p->tick));
/* If process is still active, read any output that remains. */
- if (XFASTINT (p->infd))
+ if (XINT (p->infd) >= 0)
while (! EQ (p->filter, Qt)
- && read_process_output (proc, XFASTINT (p->infd)) > 0);
+ && read_process_output (proc, XINT (p->infd)) > 0);
buffer = p->buffer;